<?php use_helper('Text')?>
<script>
    function send_message(frm){
        $('#private_messages_body').css("background", "gray");
        $('#private_messages_body').css("opacity", "0.2");
    $.ajax({
    type: "POST",
    url: $(frm).attr('action'),
    data: $(frm).serialize(),
    success: function(data){
        if($('#private_messages_body').val() != ''){
            $('#private_messages_list_ul').append('<li>'+$('#private_messages_body').val()+'</li>')
            $('#private_messages_body').val('');
        }
        $('.notification_mesage').show();
        $('.notification_mesage').html(data);
        
        $('#private_messages_body').css("background", "white");
        $('#private_messages_body').css("opacity", "1");
    }
 });
 return false;
 }
 function openMessages(obj){
 $(obj).parents('div.message_body').css("background", "gray");
 $(obj).parents('div.message_body').css("opacity", "0.2");
  $.ajax({
    type: "POST",
    url: $(obj).attr('href'),
    success: function(data){
        $parent_div = $(obj).parents('div.message_body')
        $(obj).parents('div.message_body').html(data);
        $parent_div.css("background", "none");
        $parent_div.css("opacity", "1");
    }
})
return false;
 }
</script>
<?php include_partial('private_messages/list',array('messages'=>$messages,'user_id'=>$user_id)); ?>
<div class="private_messages_form" id="private_messages_form">
    <p class="notification_mesage" style="display: none;"></p> 
<form action="<?php echo url_for('private_messages/add') ?>" method="POST" onSubmit="send_message(this);return false">
    <label><?php echo __('Message body') ?></label>
    <textarea id="private_messages_body" name="private_messages_body"></textarea>
    <input type="submit" value="<?php echo __('Send Message')?>" id="private_messages_form_submit"/>
</form>
    <div class="clear"></div>
</div>